package com.qeado.content.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qeado.content.dao.CompanyInfoDao;
import com.qeado.content.model.CompanyInfo;
import com.qeado.content.service.CompanyInfoService;

@Service
public class CompanyInfoServiceImpl implements CompanyInfoService {
	@Autowired
	private CompanyInfoDao companyInfoDao;

	@Override
	public void deleteCompanyInfo(CompanyInfo companyInfo) {
		companyInfoDao.deleteCompanyInfo(companyInfo);
	}

	@Override
	public CompanyInfo getCompanyLogoById(String id) {
		return companyInfoDao.getCompanyLogoById(id);
	}

	@Override
	public String saveCompanyInfo(CompanyInfo companyInfo) {
		if("".equals(companyInfo.getId())) {
			if(companyInfoDao.validateCompanyName(companyInfo.getCompanyName()) != null) 
				return "该公司名已存在！";
			companyInfo.setId(UUID.randomUUID().toString());
			companyInfoDao.saveCompanyInfo(companyInfo);
		} else {
			companyInfoDao.updateCompanyInfo(companyInfo);
		}
		return null;
	}

	@Override
	public List<CompanyInfo> searchCompanyInfo(CompanyInfo companyInfo) {
		return companyInfoDao.searchCompanyInfo(companyInfo);
	}

	@Override
	public CompanyInfo searchCompanyInfoById(String id) {
		return companyInfoDao.searchCompanyInfoById(id);
	}

	@Override
	public List<CompanyInfo> getCompanyCategoryList() {
		return companyInfoDao.getCompanyCategoryList();
	}

	@Override
	public List<CompanyInfo> getCompanyIndustryCategoryList() {
		return companyInfoDao.getCompanyIndustryCategoryList();
	}

	@Override
	public List<CompanyInfo> getCompanyIndustryList() {
		return companyInfoDao.getCompanyIndustryList();
	}

	@Override
	public List<CompanyInfo> getCompanyManagementModeList() {
		return companyInfoDao.getCompanyManagementModeList();
	}

}
